var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all) __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if ((from && typeof from === 'object') || typeof from === 'function') {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, {
          get: () => from[key],
          enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
        });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: true }), mod);

// src/EnhancedText/useMask.ts
var useMask_exports = {};
__export(useMask_exports, {
  default: () => useMask,
});
module.exports = __toCommonJS(useMask_exports);
var import_utils = require('@szzj/utils');
var import_react = require('react');
var maskMethodMap = {
  name: import_utils.maskName,
  idCardForce: import_utils.maskIdCardForce,
  idCardNormal: import_utils.maskIdCardNormal,
  cellphone: import_utils.maskCellphone,
  fixedPhone: import_utils.maskFixedPhone,
  email: import_utils.maskEmail,
  bankCard: import_utils.maskBankCard,
};
function useMask({ data, maskType, maskOptions }) {
  const [masked, setMasked] = (0, import_react.useState)(true);
  const toggle = (0, import_react.useCallback)(() => {
    setMasked((m) => !m);
  }, []);
  const result = (0, import_react.useMemo)(() => {
    if (masked && data) {
      if (maskType && maskMethodMap[maskType]) return maskMethodMap[maskType](String(data));
      if (maskOptions) return (0, import_utils.mask)(String(data), maskOptions);
      return String(data).replace(/./g, '*');
    }
    return data;
  }, [data, masked, maskType, maskOptions]);
  return {
    result,
    masked,
    toggle,
  };
}
